from appium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class Base:
    def __init__(self):
        cap={
              "platformName": "Android",
              "deviceName": "emulator-5554",
              "automationName": "uiautomator2",
              "appPackage": "com.xiachufang",
              "appActivity": ".activity.home.HomeActivity",
              "noReset": True
            }
        self.driver=webdriver.Remote('http://127.0.0.1:4723/wd/hub',cap)
        self.driver.implicitly_wait(10)
    # 查找元素
    def find_yuanshu(self,loc):
        ele=self.driver.find_element(*loc)
        return ele
    # 隐式等待
    def find_wait(self,loc):
        WebDriverWait(self.driver,10).until(EC.element_to_be_clickable(loc))
    # 截图
    def find_jeitu(self,a):
        ele=self.driver.save_screenshot(a)
        return ele
    # 退出
    def find_tuichu(self):
        self.driver.quit()
    # 轻敲
    def find_qingqiao(self,a,b):
        ele=self.driver.tap([a,b],200)
        return ele
    # 滑动
    def find_hua(self,a,b,c,d):
        ele=self.driver.swipe(a,b,c,d,200)
        return ele